from pydantic import BaseModel, Field
from typing import Optional, Dict, Any, List
from datetime import datetime
from uuid import UUID


class VideoUploadRequest(BaseModel):
    """视频上传请求"""
    title: str = Field(..., description="视频标题", min_length=1, max_length=255)
    description: Optional[str] = Field(None, description="视频描述", max_length=1000)
    target_platform: str = Field(..., description="目标平台", min_length=1)


class VideoUploadResponse(BaseModel):
    """视频上传响应"""
    task_id: UUID = Field(..., description="任务ID")
    message: str = Field(..., description="响应消息")


class VideoTaskResponse(BaseModel):
    """视频任务响应"""
    id: UUID
    title: str
    description: Optional[str]
    original_filename: str
    target_platform: str
    status: str
    progress: float
    current_step: Optional[str]
    error_message: Optional[str]
    output_video_url: Optional[str]
    thumbnail_url: Optional[str]
    duration: Optional[float]
    format: Optional[str]
    file_size: Optional[int]
    processing_time: Optional[float]
    created_at: datetime
    updated_at: Optional[datetime]
    started_at: Optional[datetime]
    completed_at: Optional[datetime]

    class Config:
        from_attributes = True


class VideoTaskListResponse(BaseModel):
    """视频任务列表响应"""
    tasks: List[VideoTaskResponse]
    total: int
    page: int
    size: int


class VideoProgressUpdate(BaseModel):
    """视频进度更新"""
    task_id: UUID
    status: str
    progress: float
    current_step: Optional[str]
    message: Optional[str]


class PlatformTemplateResponse(BaseModel):
    """平台模板响应"""
    id: int
    platform_name: str
    template_name: str
    display_name: str
    description: Optional[str]
    target_duration: Optional[int]
    max_segments: Optional[int]
    is_active: bool

    class Config:
        from_attributes = True


class VideoPreviewRequest(BaseModel):
    """视频预览请求"""
    task_id: UUID = Field(..., description="任务ID")